<!--
 * @Author: 高瑞寒 15932717091@163.com
 * @Date: 2022-04-18 10:21:03
 * @LastEditTime: 2022-04-18 16:31:33
 * @LastEditors: 高瑞寒 15932717091@163.com
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>details 标签</title>
  <style>
    nav {
      background: #eee;
      padding-left: 40px;
      display: flex;
      gap: 20px;
      align-items: center;
      user-select: none;
    }

    details summary {
      width: fit-content;
      padding: 5px 28px;
      height: 28px;
      line-height: 28px;
    }

    /* 打开或悬停样式 */
    [open] summary,
    details summary:hover {
      background-color: #fff;
      box-shadow: inset 1px 0 #eee, inset -1px 0 #eee;
    }

    /* 隐藏原始三角 */
    details ::marker {
      font-size: 0;
    }

    /* 自定义三角 */
    summary::after {
      content: '▼';
      margin-left: .3ch;
      color: grey;
      position: absolute;
      transition: transform .2s;
    }

    details:not([open]) summary::after {
      transform: rotate(-90deg);
    }



    .box {
      position: absolute;
      min-width: 120px;
      border: 1px solid #ddd;
      border-top: 0;
      box-sizing: border-box;
    }

    .box div {
      padding: 8px 10px;
      cursor: pointer;
    }

    .box div:hover {
      background: #eee;
    }

    .box div sup {
      display: inline-block;
      width: 18px;
      height: 18px;
      text-align: center;
      line-height: 18px;
      border-radius: 50%;
      color: #fff;
      background: #d50000;
    }
  </style>
</head>

<body>
  <nav>
    <details open>
      <summary>
        我的消息
      </summary>
      <div class="box">
        <div>我的私信<sup>12</sup></div>
        <div>我的回答</div>
        <div>我的关注</div>
      </div>
    </details>
    <details>
      <summary>
        订单中心
      </summary>
      <div class="box">
        <div>我的私信<sup>12</sup></div>
        <div>我的回答</div>
        <div>我的关注</div>
      </div>
    </details>
    <details>
      <summary>
        资产中心
      </summary>
      <div class="box">
        <div>我的私信<sup>12</sup></div>
        <div>我的回答</div>
        <div>我的关注</div>
      </div>
    </details>
  </nav>

</body>

</html>